<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require('../db_conn.php');

$rec=isset($_GET['rec'])?$_GET['rec']:"";
date_default_timezone_set('prc');
if ($rec=='insert')
{
    $name=$_POST['name'];
    $e_mail=$_POST['e_mail'];
    $password=$_POST['password'];
    $password_confirm=$_POST['password_confirm'];
    $addtime=date('Y-m-d');
    if($password==$password_confirm)
    {
    $sql="insert into td_manager(username,password,e_mail,addtime) values('$name','$password','$e_mail','$addtime')";
    
    $rs=$db->query($sql);
        if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加失败！');";
        echo "window.location.href='addmanager.php'";
        echo "</script>";
    }
    else
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加成功！');";
        echo "window.location.href='manager.php'";
        echo "</script>";  
    }
    }
 else 
     {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加失败！');";
        echo "window.location.href='addmanager.php'";
        echo "</script>";
    }

}

require ('addmanager_html.php');

$db->close();